package com.jfok.server.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.jfok.shared.TreeNodeRecordChecked;
import com.jfok.server.service.UserService;

@Controller
@RequestMapping("/user")
public class UserController {

	@Resource
	private UserService userService;


	@RequestMapping("/getuserfieldreadonlyroles.do")
	public @ResponseBody
	List<TreeNodeRecordChecked> getFieldReadonlyRolesWithEmployeeId(Integer userId) {
		return userService.getFieldReadonlyRolesWithEmployeeId(userId);
	}

	@RequestMapping("/saveuserfieldreadonlyroles.do")
	public @ResponseBody
	Boolean setFieldReadonlyRolesWithEmployeeId(Integer userId, String noderecords) {
		return userService.setFieldReadonlyRolesWithEmployeeId(userId, noderecords);
	}

	
	@RequestMapping("/getuserroles.do")
	public @ResponseBody
	List<TreeNodeRecordChecked> getRolesWithEmployeeId(Integer userId) {
		return userService.getRolesWithEmployeeId(userId);
	}

	@RequestMapping("/saveuserroles.do")
	public @ResponseBody
	Boolean setRolesWithEmployeeId(Integer userId, String noderecords) {
		return userService.setRolesWithEmployeeId(userId, noderecords);
	}

	@RequestMapping("/getuserfieldroles.do")
	public @ResponseBody
	List<TreeNodeRecordChecked> getFieldRolesWithEmployeeId(Integer userId) {
		return userService.getFieldRolesWithEmployeeId(userId);
	}

	@RequestMapping("/saveuserfieldroles.do")
	public @ResponseBody
	Boolean setFieldRolesWithEmployeeId(Integer userId, String noderecords) {
		return userService.setFieldRolesWithEmployeeId(userId, noderecords);
	}

	@RequestMapping("/resetpassword.do")
	public @ResponseBody
	Boolean resetPassword(Integer userId) {
		return userService.resetPassword(userId);
	}

	@RequestMapping("/changepassword.do")
	public @ResponseBody
	Boolean changePassword(String oldPassword, String newPassword, HttpServletRequest request) {
		return userService.changePassword(oldPassword, newPassword, request);
	}

}
